package implementCallable;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;

/**
 * @author ：黄淼淳
 * @date ：2021/12/15 19:29
 * @description：测试实现callable的类
 */
public class Test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Boolean> futureTask = new FutureTask(new Demo());
        new Thread(futureTask,"张三").start();
        new Thread(futureTask,"李四").start();
        boolean o = futureTask.get();
        System.out.println(o);

       /* FutureTask<Integer> futureTask = new FutureTask<>(()->{
            System.out.println("teest");
            for (int i = 0; i < 10; i++) {
                TimeUnit.SECONDS.sleep(1);
            }
            return 12;
        });
        new Thread(futureTask,"a").start();
        System.out.println("--------------");
        Integer integer = futureTask.get();
        System.out.println(integer);
        System.out.println("--------------");*/
    }
}
